#pragma once
#include "config_struct.hpp"
#include <yaml-cpp/yaml.h>
#include <string>

namespace config {

class ConfigReader {
public:
    static ConfigReader& getInstance();
    bool init(const std::string& env = "default");
    const SoftwareConfig& getSoftwareConfig() const { return softwareConfig_; }
    const CameraConfig& getCameraConfig() const { return cameraConfig_; }
    const AlgorithmConfig& getAlgorithmConfig() const { return algorithmConfig_; }
    const NetworkConfig& getNetworkConfig() const { return networkConfig_; }
    const DisplayConfig& getDisplayConfig() const { return displayConfig_; }

private:
    ConfigReader() = default;
    ~ConfigReader() = default;
    ConfigReader(const ConfigReader&) = delete;
    ConfigReader& operator=(const ConfigReader&) = delete;

    bool loadConfig(const std::string& filename);
    YAML::Node getNode(const std::string& key) const;
    void parseConfig();

    std::string configDir_{"../config/yaml_file"};
    YAML::Node config_;
    
    SoftwareConfig softwareConfig_;
    CameraConfig cameraConfig_;
    AlgorithmConfig algorithmConfig_;
    NetworkConfig networkConfig_;
    DisplayConfig displayConfig_;
};

} // namespace config
